VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "TEF"
   ClientHeight    =   9570
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6000
   LinkTopic       =   "Form1"
   ScaleHeight     =   9570
   ScaleWidth      =   6000
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame6 
      Caption         =   "Captura Documento"
      Height          =   1935
      Left            =   240
      TabIndex        =   33
      Top             =   1440
      Width           =   5535
      Begin VB.CommandButton Command8 
         Caption         =   "Capturar LMF - Data (Completa)"
         Height          =   375
         Left            =   2880
         TabIndex        =   41
         Top             =   1440
         Width           =   2415
      End
      Begin VB.CommandButton Command7 
         Caption         =   "Capturar LMF - CRZ (Completa)"
         Height          =   375
         Left            =   240
         TabIndex        =   40
         Top             =   1440
         Width           =   2415
      End
      Begin VB.CommandButton Command6 
         Caption         =   "CapturarMFD - Data"
         Height          =   375
         Left            =   3840
         TabIndex        =   39
         Top             =   840
         Width           =   1575
      End
      Begin VB.CommandButton Command5 
         Caption         =   "Capturar LMF - Data"
         Height          =   375
         Left            =   2040
         TabIndex        =   38
         Top             =   840
         Width           =   1575
      End
      Begin VB.CommandButton Command4 
         Caption         =   "Capturar Parâmetros"
         Height          =   375
         Left            =   240
         TabIndex        =   37
         Top             =   840
         Width           =   1575
      End
      Begin VB.CommandButton Command3 
         Caption         =   "CapturarMFD - COO"
         Height          =   375
         Left            =   3840
         TabIndex        =   36
         Top             =   360
         Width           =   1575
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Capturar LMF - CRZ"
         Height          =   375
         Left            =   2040
         TabIndex        =   35
         Top             =   360
         Width           =   1575
      End
      Begin VB.CommandButton Command1 
         Caption         =   "Capturar Leitura X"
         Height          =   375
         Left            =   240
         TabIndex        =   34
         Top             =   360
         Width           =   1575
      End
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1560
      TabIndex        =   29
      Text            =   "CARTAO"
      Top             =   6120
      Width           =   3975
   End
   Begin VB.Frame Frame5 
      Caption         =   "Janelas"
      Height          =   1335
      Left            =   3720
      TabIndex        =   26
      Top             =   120
      Width           =   2175
      Begin VB.CommandButton Cmd_DesligaJanelas 
         Caption         =   "Desliga Janelas"
         Height          =   375
         Left            =   240
         TabIndex        =   28
         Top             =   720
         Width           =   1695
      End
      Begin VB.CommandButton Cmd_LigaJanelas 
         Caption         =   "Liga Janelas"
         Height          =   375
         Left            =   240
         TabIndex        =   27
         Top             =   240
         Width           =   1695
      End
   End
   Begin VB.Frame Frame4 
      Caption         =   "Status"
      Height          =   735
      Left            =   360
      TabIndex        =   15
      Top             =   6840
      Width           =   5175
      Begin VB.CommandButton Cmd_VerificarStatus 
         Caption         =   "Verificar Status"
         Height          =   375
         Left            =   2880
         TabIndex        =   17
         Top             =   240
         Width           =   1935
      End
      Begin VB.CommandButton Cmd_RetornoECF 
         Caption         =   "Retorno ECF"
         Height          =   375
         Left            =   360
         TabIndex        =   16
         Top             =   240
         Width           =   1695
      End
   End
   Begin VB.Frame Frame3 
      Caption         =   "TEF"
      Height          =   2415
      Left            =   3240
      TabIndex        =   10
      Top             =   3480
      Width           =   2295
      Begin VB.CommandButton Cmd_Emitir2Via 
         Caption         =   "Emitir 2ª Via"
         Height          =   375
         Left            =   240
         TabIndex        =   14
         Top             =   1800
         Width           =   1815
      End
      Begin VB.CommandButton Cmd_Fecha1Via 
         Caption         =   "Fechar 1ª Via"
         Height          =   375
         Left            =   240
         TabIndex        =   13
         Top             =   1320
         Width           =   1815
      End
      Begin VB.CommandButton Cmd_ImprimirTexto 
         Caption         =   "Imprimir Texto"
         Height          =   375
         Left            =   240
         TabIndex        =   12
         Top             =   840
         Width           =   1815
      End
      Begin VB.CommandButton Cmd_AbrirVinculado 
         Caption         =   "Abrir Vinculado"
         Height          =   375
         Left            =   240
         TabIndex        =   11
         Top             =   360
         Width           =   1815
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Cupom Fiscal"
      Height          =   2415
      Left            =   360
      TabIndex        =   5
      Top             =   3480
      Width           =   2295
      Begin VB.CommandButton Cmd_FechaCupom 
         Caption         =   "Fecha Cupom"
         Height          =   375
         Left            =   240
         TabIndex        =   9
         Top             =   1800
         Width           =   1695
      End
      Begin VB.CommandButton Cmd_Totalizar 
         Caption         =   "Totalizar Cupom"
         Height          =   375
         Left            =   240
         TabIndex        =   8
         Top             =   1320
         Width           =   1695
      End
      Begin VB.CommandButton Cmd_VendeItem 
         Caption         =   "Vende Item"
         Height          =   375
         Left            =   240
         TabIndex        =   7
         Top             =   840
         Width           =   1695
      End
      Begin VB.CommandButton Cmd_AbreCupom 
         Caption         =   "Abre Cupom"
         Height          =   375
         Left            =   240
         TabIndex        =   6
         Top             =   360
         Width           =   1695
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Inicialização"
      Height          =   1095
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   3495
      Begin VB.CommandButton Cmd_FechaPorta 
         Caption         =   "Fecha Porta"
         Height          =   375
         Left            =   1920
         TabIndex        =   2
         Top             =   360
         Width           =   1455
      End
      Begin VB.CommandButton Cmd_AbrePorta 
         Caption         =   "Abre Porta"
         Height          =   375
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Width           =   1575
      End
   End
   Begin VB.Label Label12 
      BackColor       =   &H00C0FFC0&
      Height          =   375
      Left            =   1320
      TabIndex        =   32
      Top             =   9240
      Width           =   3015
   End
   Begin VB.Label Subtotal 
      Caption         =   "Subtotal:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   31
      Top             =   9240
      Width           =   1095
   End
   Begin VB.Label Label11 
      Caption         =   "Finalizadora:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   30
      Top             =   6120
      Width           =   1455
   End
   Begin VB.Label Label10 
      Caption         =   "ST3"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3840
      TabIndex        =   25
      Top             =   7800
      Width           =   615
   End
   Begin VB.Label Label9 
      Caption         =   "ST2"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2760
      TabIndex        =   24
      Top             =   7800
      Width           =   615
   End
   Begin VB.Label Label8 
      Caption         =   "ST1"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1680
      TabIndex        =   23
      Top             =   7800
      Width           =   615
   End
   Begin VB.Label Label7 
      Caption         =   "Ack"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   600
      TabIndex        =   22
      Top             =   7800
      Width           =   615
   End
   Begin VB.Label Label6 
      BackColor       =   &H00E0E0E0&
      Height          =   375
      Left            =   3720
      TabIndex        =   21
      Top             =   8040
      Width           =   735
   End
   Begin VB.Label Label5 
      BackColor       =   &H00E0E0E0&
      Height          =   375
      Left            =   2640
      TabIndex        =   20
      Top             =   8040
      Width           =   735
   End
   Begin VB.Label Label4 
      BackColor       =   &H00E0E0E0&
      Height          =   375
      Left            =   1560
      TabIndex        =   19
      Top             =   8040
      Width           =   735
   End
   Begin VB.Label Label3 
      BackColor       =   &H00E0E0E0&
      Height          =   375
      Left            =   480
      TabIndex        =   18
      Top             =   8040
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "Retorno:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   4
      Top             =   8640
      Width           =   855
   End
   Begin VB.Label Label1 
      BackColor       =   &H80000009&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1320
      TabIndex        =   3
      Top             =   8640
      Width           =   4215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim retorno As Integer


Private Sub Cmd_AbreCupom_Click()
    retorno = ECF_AbreCupomMFD("", "", "")
    Label1.Caption = "AbreCupom: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Cmd_AbrePorta_Click()
    retorno = ECF_AbrePortaSerial
    'Label1.Caption = "Abre Porta Serial: " & CStr(retorno)
End Sub

Private Sub Cmd_AbrirVinculado_Click()
    retorno = ECF_AbreComprovanteNaoFiscalVinculadoMFD(Text1.Text, "00000000000200", "000000", "111.222.333/4444-55", "Sweda", "Dona Brígida, 713")
    'retorno = ECF_AbreRelatorioGerencialMFD(1)
    Label1.Caption = "Abre Comprovante:" & CStr(retorno)
    Erro_TEF
End Sub

Private Sub Cmd_DesligaJanelas_Click()
    retorno = ECF_LigaDesligaJanelas("0", "1")
    Label1.Caption = "Desliga Janelas: " & CStr(retorno)
End Sub

Private Sub Cmd_Emitir2Via_Click()
    retorno = ECF_SegundaViaNaoFiscalVinculadoMFD
   Label1.Caption = "Emiti 2ª Via: " & CStr(retorno)
   Erro_TEF
End Sub

Private Sub Cmd_Fecha1Via_Click()
    retorno = ECF_FechaComprovanteNaoFiscalVinculado
    Label1.Caption = "Fecha 1ª Via: " & CStr(retorno)
    Erro_TEF
End Sub

Private Sub Cmd_FechaCupom_Click()
    retorno = ECF_FechaCupom(Text1.Text, "A", "%", "0000", "15,00", "Volte sempre !")
    Label1.Caption = "Fecha Cupom:" & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Cmd_FechaPorta_Click()
    retorno = ECF_FechaPortaSerial
    Label1.Caption = "Fecha Porta Serial: " & CStr(retorno)
End Sub


Private Sub Cmd_ImprimirTexto_Click()
    Dim Text As String
    Dim i As Integer
    Text = Space(618)
    Text = ""
    For i = 1 To 70
       Text = Text & "Imp. TEF" & vbCrLf
    Next
    
    retorno = ECF_UsaComprovanteNaoFiscalVinculadoTEF(Text)
    Label1.Caption = "Impressão de Texto: " & CStr(retorno)
    Erro_TEF
       
End Sub

Private Sub Cmd_LigaJanelas_Click()
    retorno = ECF_LigaDesligaJanelas("1", "1")
    Label1.Caption = "Ligar Janelas: " & CStr(retorno)
End Sub

Private Sub Cmd_RetornoECF_Click()
    'Dim iAck, iSt1, iSt2, iSt3 As Integer
   
   
    
    retorno = ECF_RetornoImpressoraMFD(iAck, iSt1, iSt2, iSt3)
   
    Label3.Caption = iAck
    Label4.Caption = iSt1
    Label5.Caption = iSt2
    Label6.Caption = iSt3
    

End Sub

Private Sub Cmd_Totalizar_Click()
    Dim sSubTotal As String
    retorno = ECF_SubTotalizaCupomMFD
    Label1.Caption = "Totalizar Cupom:" & CStr(retorno)
    
    sSubTotal = Space(14) '   (iniciação exigida apenas no V Basic)
    retorno = ECF_SubTotal(sSubTotal)
    
    Label12.Caption = "R$" & sSubTotal
    
    Cmd_RetornoECF_Click
End Sub

Private Sub Cmd_VendeItem_Click()
    retorno = ECF_VendeItem("00000001", "Produto Teste", "1200", "F", "10,050", 2, "1,00", "%", "0000")
    Label1.Caption = "Vende Item: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Cmd_VerificarStatus_Click()
     

 
   retorno = ECF_VerificaEstadoImpressoraMFD(Ack, St1, St2, St3)
  Label1.Caption = "VerificaEstadoImpressoraMFD: " & CStr(retorno)
    
    Label3.Caption = CStr(Ack)
    Label4.Caption = CStr(St1)
    Label5.Caption = CStr(St2)
    Label6.Caption = CStr(St3)
    

End Sub

Private Sub Command1_Click()
    retorno = ECF_CapturaDocumentos("0", "", "", "C:\LeituraX.txt", "1")
    Label1.Caption = "Captura da Leitura X: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Command2_Click()
    retorno = ECF_CapturaDocumentos("1", "0001", "0005", "C:\LMF-CRZ.txt", "0")
    Label1.Caption = "Captura da Leitura LMF - CRZ: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Command3_Click()
    retorno = ECF_CapturaDocumentos("5", "0000001", "000010", "C:\MFD-COO.txt", "0")
    Label1.Caption = "Captura da MFD - COO: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Command4_Click()
    retorno = ECF_CapturaDocumentos("7", "", "", "C:\Parametros.txt", "0")
    Label1.Caption = "Captura da Leitura de Parâmetros: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Command5_Click()
    retorno = ECF_CapturaDocumentos("3", "01" & Format(Now, "mmyy"), Format(Now, "ddmmyy"), "C:\LMF-Data.txt", "0")
    Label1.Caption = "Captura da Leitura LMF - Data: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Command6_Click()
    retorno = ECF_CapturaDocumentos("6", "01" & Format(Now, "mmyy"), Format(Now, "ddmmyy"), "C:\MFD-Data.txt", "0")
    Label1.Caption = "Captura da MFD - Data: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Command7_Click()
    retorno = ECF_CapturaDocumentos("2", "0001", "0005", "C:\LMF-CRZ-Completa.txt", "0")
    Label1.Caption = "Captura da Leitura LMF Completa - CRZ: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Command8_Click()
    retorno = ECF_CapturaDocumentos("4", "01" & Format(Now, "mmyy"), Format(Now, "ddmmyy"), "C:\LMF-Data-Completa.txt", "0")
    Label1.Caption = "Captura da Leitura LMF Completa - Data: " & CStr(retorno)
    Cmd_RetornoECF_Click
End Sub

Private Sub Form_Load()
    retorno = ECF_AbrePortaSerial
    'Label1.Caption = "Abre Porta Serial: " & CStr(retorno)
    

End Sub

Private Sub Form_Unload(Cancel As Integer)
    retorno = ECF_FechaPortaSerial
End Sub

Sub Erro_TEF()
    'Dim iAck, iSt1, iSt2, iSt3 As Integer
    Dim MSG As String
    retorno = ECF_RetornoImpressoraMFD(iAck, iSt1, iSt2, iSt3)
   
    Label3.Caption = iAck
    Label4.Caption = iSt1
    Label5.Caption = iSt2
    Label6.Caption = iSt3
    
    If (iSt1 <> 0) Or (iSt2 <> 0) Or (iSt3 <> 0) Then
        MSG = MsgBox("Reimprimir o TEF???", vbOKCancel)
        If MSG = vbOK Then
            MsgBox ("Reimpressão do TEF!!!")
        Else
            MsgBox ("Cancelar TEF!!!")
        End If
    End If
End Sub
